package com.demo;

public class CD extends Item{
    private  String artist;
    private int numOfTracks;


    public CD(String title, String artist, int numOfTracks, int playingTime, String comment) {
        //调用父类构造方法
        super(title,playingTime,false,comment);
        this.artist = artist;
        this.numOfTracks = numOfTracks;
    }

    @Override
    public void print() {
        System.out.print("CD : ");
        super.print();
        System.out.println( " artist:"+artist);

    }

    @Override
    public String toString() {
        return "CD{" +
                "artist='" + artist + '\'' +
                ", numOfTracks=" + numOfTracks +
                '}';
    }

    @Override
    public boolean equals(Object o) {

        //以下代码自动生成
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CD cd = (CD) o;

        return artist != null ? artist.equals(cd.artist) : cd.artist == null;
    }


}
